import React from 'react';
import ReactDOM from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom';
import { Provider } from 'react-redux';
import { configureStore } from '@reduxjs/toolkit';
import Routes from './routes';
import homeReducer from './store/home';

const App = () => {
  const store = configureStore({
    reducer: {
      home: homeReducer,
    },
    preloadedState: window.__PRELOADED_STATE__,
  });
  delete window.__PRELOADED_STATE__;

  return (
    <Provider store={store}>
      <BrowserRouter>
        <Routes />
      </BrowserRouter>
    </Provider>
  );
};

ReactDOM.hydrateRoot(document.getElementById('root'), <App />);
